//
//  CalendarCollectionViewLayout.h
//  OfficeBook
//
//  Created by 孙晓奇 on 15/9/25.
//  Copyright © 2015年 sunny. All rights reserved.
//

#import <UIKit/UIKit.h>

extern NSString * const MSCollectionElementKindTimeRowHeader;
extern NSString * const MSCollectionElementKindDayColumnHeader;
extern NSString * const MSCollectionElementKindTimeRowHeaderBackground;
extern NSString * const MSCollectionElementKindDayColumnHeaderBackground;

extern NSString * const MSCollectionElementKindCurrentTimeIndicator;
extern NSString * const MSCollectionElementKindCurrentTimeVerticalGridline;

extern NSString * const MSCollectionElementKindVerticalGridline;
extern NSString * const MSCollectionElementKindVerticalDashGridline;

typedef NS_ENUM(NSUInteger, MSHeaderLayoutType) {
    MSHeaderLayoutTypeTimeRowAboveDayColumn,
    MSHeaderLayoutTypeDayColumnAboveTimeRow
};


@class CalendarCollectionViewLayout;
@protocol MSCollectionViewCalendarLayoutDelegate <UICollectionViewDelegate>

@required
- (NSDate *)collectionView:(UICollectionView *)collectionView layout:(CalendarCollectionViewLayout *)collectionViewCalendarLayout startTimeForItemAtIndexPath:(NSIndexPath *)indexPath;
- (NSDate *)collectionView:(UICollectionView *)collectionView layout:(CalendarCollectionViewLayout *)collectionViewCalendarLayout endTimeForItemAtIndexPath:(NSIndexPath *)indexPath;
-(NSDateComponents *)dayForSection:(NSInteger)section;     //获取段所在日期
- (NSDate *)currentTimeComponentsForCollectionView:(UICollectionView *)collectionView layout:(CalendarCollectionViewLayout *)collectionViewCalendarLayout;

- (void)collectionView:(UICollectionView *)collectionView dateTitleAtCurrentSection:(NSInteger)section;
@end


@interface CalendarCollectionViewLayout : UICollectionViewLayout

@property (nonatomic, weak) id<MSCollectionViewCalendarLayoutDelegate> delegate;

@property (nonatomic) CGFloat collectionViewHeight;
@property (nonatomic) CGFloat sectionHeight;
@property (nonatomic) CGFloat itemHeight;

@property (nonatomic) CGFloat hourWidth;
@property (nonatomic) CGFloat minuteWidth;  // 1/60 * hourWidth

@property (nonatomic) CGFloat dayColumnHeaderWidth;
@property (nonatomic) CGFloat timeRowHeaderHeight;

@property (nonatomic) CGSize currentTimeIndicatorSize;
@property (nonatomic) CGFloat currentTimeVerticalGridlineWidth;
@property (nonatomic) CGFloat verticalGridlineWidth;

@property (nonatomic) UIEdgeInsets contentMargin;
@property (nonatomic) UIEdgeInsets cellMargin;
@property (nonatomic) MSHeaderLayoutType headerLayoutType;
@property (nonatomic) BOOL displayHeaderBackgroundAtOrigin;

- (void)scrollCollectionViewToClosetSectionToCurrentTimeAnimated:(BOOL)animated;
- (void)invalidateLayoutCache;
-(NSDate *)timeAtPoint:(CGPoint)point;
+(NSDate *)formatEventTime:(NSDate *)date;

- (void)minuteTick:(id)sender;
@end
